<?php defined('SYSPATH') or die('No direct script access.');

class Model_Blog extends ORM {

  protected $_table_name = 'blogs';
  protected $_sorting = array('id' => 'desc');

  protected $_has_many = array(
      'blogs_tag' => array('through' => 'blogs_blogs_tags'),
      'blog_comments' => array('model' => 'comments_blog', 'foreign_key' => 'blog_id'),
  );

  public function validate_add($array) {

    $validation = Validate::factory($array)
                    ->rule('title', 'not_empty')
                    ->rule('seo_title', 'not_empty')
                    ->rule('text', 'not_empty')
                    ->rule('tags', 'is_array');

    return $validation;
  }

}
